<?php 

/**
 * [CT 时间转换]
 * @Author   Xuebingsi
 * @DateTime 2017-03-08T08:56:40+0800
 * @param    [int]                   $time [时间戳]
 */
function CT($time)
{
    $diff = time()-$time;
    if($diff<60){
        return "刚刚";
    }elseif($diff<3600){
        return round($diff/60)."分钟之前";
    }elseif($diff<86400){
        return round($diff/60/60)."小时之前";
    }elseif($diff<(86400*7)){
        return round($diff/86400)."天之前";
    }else{
        return date('Y-m-d H:i:s',$time);
    }
}


        function xbsemail($email,$title,$content)
        {

            // require 'PHPMailerAutoload.php';
            Vendor('PHPMailer.PHPMailerAutoload');

            $mail = new PHPMailer;
            

            //$mail->SMTPDebug = 3;                               // Enable verbose debug output

            $mail->isSMTP();                                      // Set mailer to use SMTP
            $mail->Host = 'smtp.qq.com';  // 发件服务器Specify main and backup SMTP servers
            $mail->SMTPAuth = true;                               // Enable SMTP authentication
            $mail->Username = '604898904@qq.com';                 // SMTP username
            $mail->Password = 'hhpzlmdgtnscbfbg';                           // SMTP password
            $mail->SMTPSecure = 'ssl';                            //加密类型 Enable TLS encryption, `ssl` also accepted
            $mail->Port = 465;                                    // 发送服务器TCP port to connect to

            $mail->setFrom('604898904@qq.com', '何先生');//发送人
            $mail->addAddress($email, '接收人');     // Add a recipient接收人
            #$mail->addAddress('ellen@example.com');               // 可以多个接收人Name is optional
            #$mail->addReplyTo('info@example.com', 'Information');//回复什么之类的
            #$mail->addCC('cc@example.com');
            #$mail->addBCC('bcc@example.com');//抄送

            #$mail->addAttachment('/var/tmp/file.tar.gz');         // 附件Add attachments
            #$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
            $mail->isHTML(true);                                  // Set email format to HTML

            $mail->Subject = $title;
            $mail->Body    = $content;
           

            if(!$mail->send()) {
                // echo 'Message could not be sent.';
                // echo 'Mailer Error: ' . $mail->ErrorInfo;
                return false;
            } else {
                // echo 'Message has been sent';
                return true;
            }

        }

        //qq互联的函数类接口函数 登录
        
         function helogin()
        {
            Vendor('QQConnect.API.qqConnectAPI');
            $qc = new \QC();
            $qc->qq_login();
        }
        

        //获取接口id
        function getOpenid()
        {
             Vendor('QQConnect.API.qqConnectAPI');
             $qc = new \QC();
             $qc->qq_callback();
            
            return $qc->get_openid();
        }   

        //获取用户信息
        function getUserInfo()
        {

            Vendor('QQConnect.API.qqConnectAPI');

            $qc = new \QC();

            return $qc->get_user_info();
        }
        function xbs($str)
        {
            $preg = '/(@)(.+)@/';
            $url = U('home/u/find_nick');
            $str1 = preg_replace( $preg,"$1<a href='".$url."?nickname=$2'>$2</a>", $str);

            return $str1;
        }












 ?>